package java113.project.base;

public class Order {


    private String customerName;
    private int customerNumber;
    private double extendedPrice;
    private String item;
    private int quantity;
    private double unitPrice;
    private double handlingCharge;
    
    private double total;

    private int[] hChargeQuantity;
    private double[] hChargeAmount;

    public Order() {
        
    }


    public void setCustomerName(String s) {
        this.customerName = s;
    }


    public String getCustomerName() {
        return this.customerName;
    }


    public void setCustomerNumber(int i) {
        this.customerNumber = i;
    }


    public int getCustomerNumber() {
        return this.customerNumber;
    }


    public void setExtendedPrice(double d) {
        this.extendedPrice = d;
    }


    public double getExtendedPrice() {
        calExtendedPrice();
        return this.extendedPrice;
    }


    public void setItem(String s) {
        this.item = s;
    }


    public String getItem() {
        return this.item;
    }


    public void setQuantity(int i) {
        this.quantity = i;
    }


    public int getQuantity() {
        return this.quantity;
    }


    public void setUnitPrice(double d) {
        this.unitPrice = d;
    }


    public double getUnitPrice() {
        return this.unitPrice;
    }


    public void setHandlingCharge(double d) {
        this.handlingCharge = d;
    }


    public double getHandlingCharge() {

        calHandlingCharge();
        
        return this.handlingCharge;
    }


    public void setHChargeQuantity(int[] i) {
        this.hChargeQuantity = i;
    }


    public int[] getHChargeQuantity() {
        return this.hChargeQuantity;
    }


    public void setHChargeAmount(double[] d) {
        this.hChargeAmount = d;
    }


    public double[] getHChargeAmount() {
        return this.hChargeAmount;
    }


    public void calExtendedPrice() {
        setExtendedPrice(this.quantity * this.unitPrice);
    }


    public void calHandlingCharge() {
        double  d  = 0;
        for (int i = 0; i < this.hChargeQuantity.length; i++) {
            if (this.quantity < this.hChargeQuantity[i]) {
                if (this.quantity>0) {
                    setHandlingCharge(this.hChargeAmount[i - 1]);
                }
                else {
                    setHandlingCharge(this.hChargeAmount[0]);
                }
                return;
            }
            d = this.hChargeAmount[i];
        }
        setHandlingCharge(d);
    }
    
    public void setTotal(double total) {
        
        this.total = total;
        
    }
    
    public double getTotal() {
        
        this.total = getExtendedPrice() + getHandlingCharge();
        
        return this.total;
        
    }

    @Override
    public String toString() {
        
        return  "Customer :" + getCustomerName() +
                "\nItem Ordered: " + getItem() +
                "\nUnit Price: $" + getUnitPrice() +
                "\nQuantity Ordered: " + getQuantity() +
                "\nTotal: $" + getExtendedPrice() +
                "\n" +
                "\nPlus a $" + getHandlingCharge() + " processing charge" +
                "\nGrand Total: " + getTotal() +
                "\n\n";
    }

 }